<template>
  <div class="vuexcom">
    <p>num的自增结果是：{{num}}</p>
    <button @click="increment()">Mutation同步自增+5</button>
    <button @click="increMentAct()">Actions异步自增+5</button>
  </div>
</template>

<script setup>
import {useStore} from 'vuex';
import {computed} from 'vue';


const store = useStore();
//声明一个计算属性对象，获取store里面的state数据
let num = computed(()=>store.state.num)

//调用点击事件：触发调用store内的同步函数
const increment = ()=>{
    store.commit('addMut')
}

const increMentAct=()=>{
    store.dispatch('addAct')
}
</script>

<style>

</style>